#ifndef __XS_TIMER_H__
#define __XS_TIMER_H__


#ifdef __cplusplus
extern "C"{
#endif


#define TIMER_EXT extern
#define SYS_MAX_TIMER_NUM	10
#define SYS_TICK_MULTIPLE	1
#define ESYS_MODULE_MAX     100

typedef enum
{
	ETIMER_ONE = 1,	
	ETIMER_LOOP,	
	
}ETIMER_TYPE;

typedef enum
{
	ETIMER_IDLE = 0,	
	ETIMER_START,	
	ETIMER_STOP,	
}ETIMER_STATE;

typedef enum
{
	ETIMER_OK = 0,			
	ETIMER_PARA_ERR,		
	ETIMER_NO_EXIST,		
	ETIMER_EMPTY,			
	ETIMER_TYPE_ERR,		
	ETIMER_PROC_ERR = 0xFF,	
	
}ETIMER_RESULT;

typedef struct tSysTimerNode
{
	int timer_id;				
	int module_id;				
	ETIMER_TYPE timer_type;			
	ETIMER_STATE eState;			
	int wTickOffset;			
        unsigned short dwTimerLimit;			
	void (*pvTimeFunc)(int argc,char **argv) ;	
	int   argc;					
	char** argv;				
	struct tSysTimerNode *ptPre;		
	struct tSysTimerNode *ptNext;

}TSYS_TIMER_NODE;

typedef struct
{
	int byIdleNum;				
	int byUseNum;			
	TSYS_TIMER_NODE *ptTimerIdle;	
	TSYS_TIMER_NODE *ptTimerUse;	
	
}TSYS_TIMER_MA;


 int xs_timer_init(void);
 int xs_timer_create(int module_id, ETIMER_TYPE timer_type);
 int xs_timer_delete(int timer_id);
 int xs_timer_start(int timer_id, int timer_delay, void *timer_func,int argc,char **argv);
 int xs_timer_stop(int timer_id);
 void xs_timer_proc(void *pv_para) ;
 void xs_timer_msleep(int time_sec);

int xs_timer_test(void);
#ifdef __cplusplus
}
#endif

#endif

